package ru.amse.baltijsky.javascheme.nodeshape;

import ru.amse.baltijsky.javascheme.util.Size;
import ru.amse.baltijsky.javascheme.util.VisConst;

import java.awt.*;

/**
 * An automata-style final state shape denoting the end of the scheme.
 */
public class FinalShape extends AbstractNodeShape {
    private static final double INTERNAL_CIRCLE_SCALE = 0.85d;

    /**
     * Default constructor for an initial shape with no arguments.
     * Intended to use instead of the usual version with String.
     */
    public FinalShape() {
        super("");
    }

    /**
     * Constructs an initial shape, taking the ignored string parameter (there is no code in the initial state).
     * Used only for compatibility with major type shapes.
     */
    public FinalShape(String code) {
        this();
    }

    public void draw(int x, int y, Graphics g) {
        Color oldColor = g.getColor();

        g.setColor(VisConst.SCHEME_COL);
        int radius = ShapeTools.getCircleRadius(g);
        g.drawOval(x - radius, y - radius, radius * 2, radius * 2);
        radius *= INTERNAL_CIRCLE_SCALE;
        g.drawOval(x - radius, y - radius, radius * 2, radius * 2);

        g.setColor(oldColor);
    }

    public Size getBoundRectSize(Graphics g) {
        int diameter = 2 * ShapeTools.getCircleRadius(g);
        return new Size(diameter, diameter);
    }
}
